<?php
class homeModel extends model
{
    public function getprocess(){
        $category = $this->dao->select('*')->from(TABLE_CATEGORY)->orderBy('id desc')->fetchAll();
        foreach($category as $val){
            $process = $this->dao->select('*')->from(TABLE_PROCESS)
                ->where('category')->like('%%'.$val->id.'%%')
                ->andWhere('istrue')->eq('yes')
                ->andWhere('approval_status')->eq('final')
                ->fetchAll();
            foreach($process as $pre){
                $person = $this->dao->select('name')->from(TABLE_USERS)->where('id_card')->eq($pre->personnel)->fetch();
                $pre->personnel = $person->name;
            }
            $val->process = $process;
            if($val->process){
                $data[] = $val;
            }
        }

        return $data;
    }

}